
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>体温填报</title>
    <link rel="icon" href="/static/favicon.ico" type="image/ico">
    <meta name="keywords" content="体温填报">
    <meta name="description" content="体温填报">
    <meta name="author" content="yinqi">
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/layui/css/layui.css" rel="stylesheet">
    <link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/js/jconfirm/jquery-confirm.min.css">
    <link href="/static/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">

            <!-- logo -->
            <div class="lyear-layout-sidebar-scroll">

                <nav class="sidebar-main">
                    <ul class="nav nav-drawer">
                        <li class="nav-item nav-item-has-subnav">
                            {{if .IsLogin}}
                                <a href="/"><i class="mdi mdi-account"></i> 体温提交</a>
                                <a href="{{urlfor "TmpController.Get"}}"><i class="mdi mdi-account"></i> 员工体温信息查询</a>
                                <a href="{{urlfor "StaffController.Get"}}"><i class="mdi mdi-account"></i> 员工信息</a>
                            {{else}}
                                <a href="/"><i class="mdi mdi-account"></i> 体温提交</a>
                            {{end}}
                        </li>
                    </ul>
                </nav>
            </div>

        </aside>
        <!--End 左侧导航-->

        <!--头部信息-->
        <header class="lyear-layout-header">

            <nav class="navbar navbar-default">
                <div class="topbar">

                    <div class="topbar-left">
                        <div class="lyear-aside-toggler">
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                        </div>
                        <span class="navbar-page-title">体温填报</span>
                    </div>
                    {{if .IsLogin}}
                        <ul class="topbar-right">
                            <li class="dropdown dropdown-profile">
                                <a href="javascript:void(0)" data-toggle="dropdown">
                                    <span> Test<span class="caret"></span></span>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li class="divider"></li>
                                    <li> <a href="{{urlfor "UserController.Logout"}}"><i class="mdi mdi-logout-variant"></i> 退出登陆</a> </li>
                                </ul>
                            </li>
                        </ul>
                    {{else}}
                        <ul class="topbar-right">
                            <li class="dropdown dropdown-profile">
                                <a href="javascript:void(0)" data-toggle="dropdown">
                                    <span> 信息查询登陆<span class="caret"></span></span>
                                </a>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li class="divider"></li>
                                    <li> <a href="{{urlfor "UserController.Get"}}"><i class="mdi mdi-logout-variant"></i> 登陆</a> </li>
                                </ul>
                            </li>
                        </ul>
                    {{end}}

                </div>
            </nav>

        </header>
        <!--页面主要内容-->
    <main class="lyear-layout-content">
        <div class="container-fluid">
          <div class="row">
            <div class="card">
              <div class="card-header"><h3>员工信息<h3></div>
            <div class="input-group m-b-10">
                <button type="submit" class="btn btn-success btn-w-md" onclick="createStaff();">添加人员</button>
            </div>
        <div>
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
    <!--End 页面主要内容-->
  </div>
</div>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script src="/static/layui/layui.all.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/static/js/main.min.js"></script>
<script src="/static/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/static/js/messagebox.js"></script>
<!--时间选择插件-->
<script src="/static/js/bootstrap-datetimepicker/moment.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker/locale/zh-cn.js"></script>
<!--日期选择插件-->
<script src="/static/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="/static/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript">
layui.use('table', function(){
  var table = layui.table;
  table.render({
    elem: '#test'
    ,url:'{{urlfor "StaffController.GetStaffs"}}'
    ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print']
    ,limit: 100
    ,title:'员工信息表'
    ,cols: [[
      {field:'id', title: 'ID'}
      ,{field:'name', title: '姓名', sort: true}
      ,{field:'createtime', title: '创建时间'}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
    ]]
  });
  table.on('tool(test)', function(obj){
    var data = obj.data;
    //console.log(obj)
    if(obj.event === 'del'){
      layer.confirm('真的删除行么', function(index){
        $.ajax({
            url:'/del_staff',
            type:'POST',
            data:{'id':data.id},
            dataType:"json",
            success:function(data){
                console.log(data);
                if(data.Status){
                    layer.msg(data.Msg);
                    obj.del();
                }
                else{
                    layer.msg(data.Msg);}
            }
        })
      });
    } else if(obj.event === 'edit'){
      layer.prompt({
        formType: 2
        ,value: data.name
      }, function(value, index){
        obj.update({
          email: value
        });
        layer.close(index);
      });
    }
  });
});
createStaff = function(){
    layer.open({
        type:1,
        title:'添加人员',
        area:'300px;',
        id:'createPro',//配置ID
        content: $('#create-project-div'),
        btn:['确定','取消'], //添加按钮
        btnAlign:'c', //按钮居中
        yes:function (index,layero) {
            data = {
                'name':$("#name").val(),
            }
            $.post("{{urlfor "StaffController.Create"}}",data,function(r){
                if(r.Status){
                    //创建成功
                    layer.msg(r.Msg);
                    window.location = "{{urlfor "StaffController.Get"}}"
                    //layer.close(index)
                }else{
                    //创建失败，提示
                    layer.msg(r.Msg);

                }
            })
        },
    });
};
</script>
<div style="padding: 20px;display:none;" id="create-project-div">
    <input class="layui-input" type="text" id="name" style="margin-bottom:10px;" placeholder="输入姓名" required  lay-verify="required">
</div>
</body>
</html>